window.views = window.views || {}
window.views.editor = window.views.editor || {}
window.views.editor.enable = function(){
		tinymce.init({
		    selector: "h1.editable",
		    inline: true,
		    toolbar: "undo redo",
		    menubar: false
		});

		tinymce.init({
		    selector: "div.editable",
		    inline: true,
		    plugins: [
		        "advlist autolink lists link image charmap print preview anchor",
		        "searchreplace visualblocks code fullscreen",
		        "insertdatetime media table contextmenu paste"
		    ],
		    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
		});
	}
window.views.editor.disable = function(){


	}
window.views.editor.save =function(){
		var $h1 = $(".h1-editable").html();
		var $div = $(".div-editable").html();
		var $desc = $(".description-editable").html();

		var num = window.views.editor.url;
		var project = 0;
		if( num === parseInt(num) ){
			project = 1;
		}

		var post_data = {
			'title':$h1,
			'text':$div,
			'description': ($desc === undefined ? '' : $desc ),
			'project':project,
			'oper':"edit"
		}	

		var url = window.views.editor.base_url + 'texts' + window.views.editor.url;

		$.post(url, post_data, function(resp){
			//console.log(resp);
			//window.location.reload();
		});

	
}

window.views.editor.select = function(e){
		console.log(e);
}